#----------------------------------------
# 可执行文件名称
#----------------------------------------
app = mdget

#----------------------------------------
# main package entry
#----------------------------------------
main = main.go

ifeq ($(OS), Windows_NT)
	exec = $(app).exe
else
	exec = $(app)
endif

#----------------------------------------
# 交叉编译设置
#----------------------------------------
set_env := 
# set_env = export CGO_ENABLED=1; export GOOS=linux; export GOMIPS=softfloat; export GOARCH=mipsle
# set_env = export GOOS=windows

#----------------------------------------
# 链接参数设置
#----------------------------------------
# LD_FLAG = -ldflags="-s -w"

#----------------------------------------
# 编译后命令执行
#----------------------------------------
script_do := cp $(exec) "d:\Program Files\app"

all: ${exec}

$(exec): $(wildcard *.go) 
	go build $(LD_FLAG) -o $@ ${main}
	$(script_do)

zip:
	upx -9 ./$(exec)

up: 
	scp ./$(exec) root@10.10.10.1:/tmp

init:
	go mod init example.com/m/v2
	go mod tidy

.PHONY: clean
clean:
	-rm -f $(exec)